<template>
  <div class="labelMain" @click="gotoLabel" @contextmenu="rightClickDeskNavEvent">

    <div class="relative z-10">
      <div class="w-[55px] h-[55px] rounded-2xl" style="display: none;">
        <img src="" alt="" srcset="" class="w-[100%] h-[100%] rounded-xl">
      </div>
      <div class="text-[#94b1e5] w-[50px] h-[50px] flex text-[40px] justify-center font-[950]">
        {{firstName}}
      </div>
    </div>

    <div class="text-name">
        {{labelContent.name}}
    </div>
    <div class="bgcontent">
      <div class="w-[120px] h-[120px] rounded-2xl translate-x-[0%] translate-y-[10%] rotate-[10deg]" style="display: none;">
        <img src="" alt="" srcset="" class="w-[100%] h-[100%] rounded-2xl">
      </div>
      <div class="bg-text text-[#94b1e5]">
        {{firstName}}
      </div>
    </div>

  </div>
</template>

<script setup>
import { onMounted , computed } from 'vue'
import { toRefs } from 'vue'
import { storeToRefs } from "pinia";
import { useLabelBarStore } from "@/stores/labelBar"
let { menuClickSlove } = useLabelBarStore()
 
const props = defineProps({
  labelContent: Object,
  index: Number
})
const {labelContent , index} =toRefs(props)

const firstName = computed(() => {
  return labelContent.value.name[0]
})

const gotoLabel = () => {
  window.open(labelContent.value.url)
}

//右键点击事件
const rightClickDeskNavEvent = (e) => {
      // 取消默认的右键菜单
      e.preventDefault()

      menuClickSlove(e)

}
onMounted(() => {
  
})
</script>

<style scoped lang="scss">
.labelMain {
    cursor: pointer;
    background-color: var(--deskNavigation-items-background-color);
    color: var(--deskNavigation-items-text-color);
    border-color: #00000013;
    width: 9rem;
    height: 8rem;
    display: flex;
    justify-content: space-around;
    align-items: center;
    flex-direction: column;
    border-radius: 1rem;
    border-width: 2px;
    overflow: hidden;
    position: relative;
    border: 2px solid #00000013;
    margin: 10px;
    .text-name {
      font-size: 16px;
      font-weight: 650;
      width: 80px;
      text-align: center;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      letter-spacing: 0.5px;
    }
    .bgcontent {
      opacity: 0.15;
      position: absolute;
      left: 45%;
      top: 0%;
      --tw-rotate: -40deg;
      transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
      .bg-text {
        font-weight: 950;
        font-size: 115px;
        margin-top: -10px;
      }
    }
}
.labelMain:hover {
  transition: all 0.2s linear;
  transform: scale(1.08);
}
</style>